package com.gd.iot.energy.controller.datapush;

import com.gd.iot.energy.annotation.SystemLogRecordMonitor;
import com.gd.iot.energy.entity.ResponseEntity;
import com.gd.iot.energy.pojo.datapush.ctwing.dto.DataChangeDTO;
import com.gd.iot.energy.pojo.datapush.ctwing.dto.DeviceEventDTO;
import com.gd.iot.energy.pojo.datapush.ctwing.dto.DeviceOnOfflineDTO;
import com.gd.iot.energy.pojo.datapush.ctwing.dto.DeviceResponseDTO;
import com.gd.iot.energy.service.datapush.CTWINGSubscribeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 天翼平台数据推送
 *
 * @author kris
 * @date Created at 8:41 下午 2020/8/28
 */
@RestController
@RequestMapping("/ctwing/subscribe")
@Api(value = "天翼平台数据推送",tags = "天翼平台数据推送")
public class CTWINGSubscribeController {

    @Autowired
    private CTWINGSubscribeService ctwingSubscribeService;

    @ApiOperation("数据变化")
    @SystemLogRecordMonitor("数据变化")
    @PostMapping("/changeData")
    public ResponseEntity dataChange(@RequestBody DataChangeDTO dataChangeDTO){
        ctwingSubscribeService.dataChange(dataChangeDTO);
        return new ResponseEntity();
    }

    @ApiOperation("设备响应")
    @SystemLogRecordMonitor("设备响应")
    @PostMapping("/deviceResponse")
    public ResponseEntity deviceResponse(@RequestBody DeviceResponseDTO deviceResponseDTO){
        ctwingSubscribeService.deviceResponse(deviceResponseDTO);
        return new ResponseEntity();
    }


    @ApiOperation("设备事件")
    @SystemLogRecordMonitor("设备事件")
    @PostMapping("/deviceEvent")
    public ResponseEntity deviceEvent(@RequestBody DeviceEventDTO deviceEventDTO){
        ctwingSubscribeService.deviceEvent(deviceEventDTO);
        return new ResponseEntity();
    }

    @ApiOperation("设备上下线")
    @SystemLogRecordMonitor("设备上下线")
    @PostMapping("/deviceOnOffline")
    public ResponseEntity deviceResponse(@RequestBody DeviceOnOfflineDTO deviceOnOfflineDTO){
        ctwingSubscribeService.deviceOnOffline(deviceOnOfflineDTO);
        return new ResponseEntity();
    }
}
